package com.ftg.learn.chapter19.jdbc.leetcode;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

/**
 * @author KangJx
 * @date 2021/9/2
 */
public class Solution {


    public String[] permutation(String s) {
        if(null == s){
            throw new RuntimeException("请输入案例字符");
        }
        if(s.isEmpty() || s.length() == 1){
            return new String[]{s};
        }

        StringBuilder sb = new StringBuilder(s);
        sb.append(s);

        List<String> list = new ArrayList<>(s.length());
        for(int i = 0 , len = s.length();i < len ;i++){
            for(int j = i;j < len;j++){
                list.add(sb.substring(j,j + s.length()));
            }
        }
        System.out.println(list);
        list = list.stream().distinct().collect(Collectors.toList());
        return list.toArray(new String[list.size()]);
    }


    public static void main(String[] args) {
        long a = System.currentTimeMillis();
        System.out.println(a);
        Solution s = new Solution();
        s.permutation("abcd");
        System.out.println(System.currentTimeMillis() - a);
    }
}
